﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace HYElectricSetting
{
	public partial class SelectSingleItemForm : System.Windows.Forms.Form
	{
		public SelectSingleItemForm(string title, List<string> existedItems, List<string> selectItems)
		{
			this.InitializeComponent();
			this.formTitle = title;
			this.ExistedItems = existedItems.ToList<string>();
			this.SelectItems = selectItems.ToList<string>();
			this.ResultItem = string.Empty;
		}

		private void SelectSingleItemForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			this.Text = this.formTitle;
			this.InitConduitTypeCombox();
		}

		private void InitConduitTypeCombox()
		{
			bool flag = false;
			this.cmbConduitType.Items.Clear();
			foreach (string text in this.SelectItems)
			{
				this.cmbConduitType.Items.Add(text);
				bool flag2 = !flag && !this.ExistedItems.Contains(text);
				if (flag2)
				{
					this.cmbConduitType.SelectedItem = text;
					flag = true;
				}
			}
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.ResultItem = (string)this.cmbConduitType.SelectedItem;
			bool flag = string.IsNullOrEmpty(this.ResultItem);
			if (flag)
			{
				TaskDialog.Show("盈建科提示", "还未选择线管类型，请选择。");
			}
			else
			{
				bool flag2 = this.ExistedItems.Contains(this.ResultItem);
				if (flag2)
				{
					TaskDialog.Show("盈建科提示", "已有相同名称线管类型，请重新选择。");
				}
				else
				{
					base.DialogResult = DialogResult.OK;
				}
			}
		}

		private string formTitle;

		private List<string> ExistedItems;

		private List<string> SelectItems;

		public string ResultItem;
	}
}
